package top.kaoshanji.r1ch05b;

import org.junit.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/6 14:56
 */
@ContextConfiguration("classpath*:/r1ch05b/beans.xml")
public class FactoryBeanTest extends AbstractTestNGSpringContextTests {

    @Autowired
    public ApplicationContext context;

    /**
     * 代码清单test-r1ch05b-01：测试一下FactoryBean实现类
     */
    @Test
    public void testCarFactoryBean() {
        Car car1 = context.getBean("car1", Car.class);
        Car car2 = context.getBean("car1", Car.class);

        Assert.assertNotNull(car1);
        Assert.assertNotSame(car1, car2);

        System.out.println(car1);

    }


}
